package com.xuxin.nantai.base;

import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.blankj.utilcode.util.BarUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.xuxin.nantai.bean.BaseBean;

import butterknife.ButterKnife;

/**
 * Created by xu_xin
 * Created on 2020.06.05
 */
public abstract class BaseActivity extends AppCompatActivity implements View.OnClickListener {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        try {
            BarUtils.setStatusBarVisibility(this, true);
            BarUtils.setStatusBarLightMode(this, true);
            BarUtils.setStatusBarColor(this, Color.TRANSPARENT);
            setContentView();
            ButterKnife.bind(this);
            initView();
            initData();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public abstract void setContentView();

    public abstract void initView();

    public abstract void initData();

    public abstract void onComplete();

    public void onError(BaseBean baseBean) {
        if (null != baseBean) {
            ToastUtils.showShort(baseBean.getMessage());
        } else {
            ToastUtils.showShort("网络连接异常");
        }
        onComplete();
    }
}